// Copyright (C) ZHENG Zhong <heavyzheng nospam-at gmail D0T com>
//
// $Id: attribute.hpp 318 2009-03-02 14:03:21Z heavyzheng $
//

#ifndef ZZHENG_XML_DOM_LIBXML2_ATTRIBUTE_HPP_20080717__
#define ZZHENG_XML_DOM_LIBXML2_ATTRIBUTE_HPP_20080717__

#include <zzheng/xml/config.hpp>
#include <zzheng/xml/dom/basic_node_ptr.hpp>

#include <zzheng/xml/dom/libxml2/node.hpp>
#include <zzheng/xml/dom/libxml2/callbacks.hpp>
#include <zzheng/xml/dom/libxml2/libxml2_fwd.hpp>

#include <string>

namespace zzheng {
namespace xml {
namespace dom {
namespace libxml2_ {

    class attribute_map;

    //! This class represents an XML attribute.
    class attribute: public node {

        friend void on_node_construct(xmlNode* px);
        friend class attribute_map;

    public:

        ~attribute();

        ////////////////////////////////////////////////////////////////////////////////////////////
        // property access
        //

        //! Returns the namespace URI of this attribute, or an empty string if it hasn't one.
        std::string uri() const;

        //! Returns the namespace prefix of this attribute, or an empty string if it hasn't one.
        std::string prefix() const;

        //! Returns the full qualified name of this attribute.
        std::string qname() const;

        //! Sets the local name of this attribute.
        //! \param name  the new local name to set.
        void set_name(const std::string& name);

        //! Returns the value of this attribute.
        std::string value() const;

        //! Sets the value of this attribute.
        //! \param value  the value to set.
        void set_value(const std::string& value);


        ////////////////////////////////////////////////////////////////////////////////////////////
        // sibling access
        //

        //! Returns the previous sibling.
        //! \return the previous sibling.
        basic_node_ptr<attribute> prev_sibling();

        //! Returns the next sibling.
        //! \return the next sibling.
        basic_node_ptr<attribute> next_sibling();

        //! Const version of prev_sibling().
        basic_node_ptr<const attribute> prev_sibling() const;

        //! Const version of next_sibling().
        basic_node_ptr<const attribute> next_sibling() const;

    private:

        ////////////////////////////////////////////////////////////////////////////////////////////
        // private
        //

        explicit attribute(xmlNode* px);

        attribute* clone(bool recursive) const;

        const attribute* prev_sibling_() const;

        const attribute* next_sibling_() const;

    }; // class attribute

} // namespace zzheng::xml::dom::libxml2_
} // namespace zzheng::xml::dom
} // namespace zzheng::xml
} // namespace zzheng


#endif // ZZHENG_XML_DOM_LIBXML2_ATTRIBUTE_HPP_20080717__



